package com.xigege.netty.nettyComponent.futureAndPromise;

import java.util.concurrent.*;

public class TestJDKfuture {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService threadPool = Executors.newFixedThreadPool(2);

        Future<Integer> future = threadPool.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("执行callable任务。。。");
                TimeUnit.SECONDS.sleep(5);
                return 123654;
            }
        });
        System.out.println("等待任务执行完成：");
        System.out.println("任务执行完成，结果为："+future.get());
    }
}
